<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>perlfilter - Source Filters - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/perlfilter">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlfilter.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/perlfilter">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/perlfilter">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/perlfilter">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/perlfilter">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/perlfilter">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/perlfilter">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/perlfilter">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/perlfilter">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/perlfilter">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/perlfilter">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/perlfilter">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/perlfilter">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/perlfilter">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/perlfilter">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/perlfilter">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/perlfilter">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/perlfilter">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/perlfilter">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/perlfilter">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/perlfilter">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/perlfilter">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/perlfilter">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/perlfilter">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/perlfilter">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/perlfilter">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/perlfilter">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/perlfilter">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/perlfilter">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/perlfilter">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/perlfilter">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/perlfilter">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/perlfilter">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/perlfilter">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/perlfilter">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/perlfilter">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/perlfilter">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/perlfilter">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/perlfilter">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/perlfilter">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/perlfilter">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/perlfilter">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/perlfilter">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/perlfilter">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/perlfilter">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/perlfilter">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/perlfilter">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/perlfilter">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/perlfilter">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/perlfilter">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/perlfilter">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/perlfilter">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/perlfilter">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/perlfilter">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/perlfilter">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/perlfilter">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/perlfilter">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/perlfilter">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/perlfilter">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/perlfilter">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/perlfilter">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/perlfilter">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/perlfilter">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/perlfilter">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/perlfilter">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/perlfilter">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/perlfilter">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/perlfilter">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/perlfilter">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/perlfilter">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/perlfilter">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/perlfilter">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/perlfilter">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/perlfilter">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/perlfilter">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/perlfilter">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/perlfilter">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/perlfilter">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/perlfilter">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/perlfilter">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/perlfilter">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlfilter.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/perlfilter">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/perlfilter">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/perlfilter">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/perlfilter">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/perlfilter">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/perlfilter">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/perlfilter">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/perlfilter">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/perlfilter">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/perlfilter">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/perlfilter">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/perlfilter">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/perlfilter">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/perlfilter">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/perlfilter">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/perlfilter">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/perlfilter">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/perlfilter">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/perlfilter">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/perlfilter">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/perlfilter">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/perlfilter">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/perlfilter">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/perlfilter">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/perlfilter">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/perlfilter">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/perlfilter">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/perlfilter">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/perlfilter">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/perlfilter">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/perlfilter">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/perlfilter">5.35.1</a>
          <a class="dropdown-item active" href="perlfilter.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlfilter.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="perlfilter.html">perlfilter</a>
          <div id="more">
            (<a href="perlfilter.txt">source</a>,
            <a href="https://metacpan.org/pod/perlfilter">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#CONCEPTS">CONCEPTS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#USING-FILTERS">USING FILTERS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#WRITING-A-SOURCE-FILTER">WRITING A SOURCE FILTER</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#WRITING-A-SOURCE-FILTER-IN-C">WRITING A SOURCE FILTER IN C</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#CREATING-A-SOURCE-FILTER-AS-A-SEPARATE-EXECUTABLE">CREATING A SOURCE FILTER AS A SEPARATE EXECUTABLE</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#WRITING-A-SOURCE-FILTER-IN-PERL">WRITING A SOURCE FILTER IN PERL</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#USING-CONTEXT:-THE-DEBUG-FILTER">USING CONTEXT: THE DEBUG FILTER</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#CONCLUSION">CONCLUSION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#LIMITATIONS">LIMITATIONS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#THINGS-TO-LOOK-OUT-FOR">THINGS TO LOOK OUT FOR</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#REQUIREMENTS">REQUIREMENTS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#AUTHOR">AUTHOR</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlfilter.html#Copyrights">Copyrights</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="perlfilter.html#NAME">#</a>NAME</h1>

<p>perlfilter - Source Filters</p>

<h1 id="DESCRIPTION"><a class="permalink" href="perlfilter.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>This article is about a little-known feature of Perl called <i>source filters</i>. Source filters alter the program text of a module before Perl sees it, much as a C preprocessor alters the source text of a C program before the compiler sees it. This article tells you more about what source filters are, how they work, and how to write your own.</p>

<p>The original purpose of source filters was to let you encrypt your program source to prevent casual piracy. This isn&#39;t all they can do, as you&#39;ll soon learn. But first, the basics.</p>

<h1 id="CONCEPTS"><a class="permalink" href="perlfilter.html#CONCEPTS">#</a>CONCEPTS</h1>

<p>Before the Perl interpreter can execute a Perl script, it must first read it from a file into memory for parsing and compilation. If that script itself includes other scripts with a <code>use</code> or <code>require</code> statement, then each of those scripts will have to be read from their respective files as well.</p>

<p>Now think of each logical connection between the Perl parser and an individual file as a <i>source stream</i>. A source stream is created when the Perl parser opens a file, it continues to exist as the source code is read into memory, and it is destroyed when Perl is finished parsing the file. If the parser encounters a <code>require</code> or <code>use</code> statement in a source stream, a new and distinct stream is created just for that file.</p>

<p>The diagram below represents a single source stream, with the flow of source from a Perl script file on the left into the Perl parser on the right. This is how Perl normally operates.</p>

<pre><code class="plaintext">file -------&gt; parser</code></pre>

<p>There are two important points to remember:</p>

<ol>

<li><p>Although there can be any number of source streams in existence at any given time, only one will be active.</p>

</li>
<li><p>Every source stream is associated with only one file.</p>

</li>
</ol>

<p>A source filter is a special kind of Perl module that intercepts and modifies a source stream before it reaches the parser. A source filter changes our diagram like this:</p>

<pre><code class="plaintext">file ----&gt; filter ----&gt; parser</code></pre>

<p>If that doesn&#39;t make much sense, consider the analogy of a command pipeline. Say you have a shell script stored in the compressed file <i>trial.gz</i>. The simple pipeline command below runs the script without needing to create a temporary file to hold the uncompressed file.</p>

<pre><code class="plaintext">gunzip -c trial.gz | sh</code></pre>

<p>In this case, the data flow from the pipeline can be represented as follows:</p>

<pre><code class="plaintext">trial.gz ----&gt; gunzip ----&gt; sh</code></pre>

<p>With source filters, you can store the text of your script compressed and use a source filter to uncompress it for Perl&#39;s parser:</p>

<pre><code class="plaintext"> compressed           gunzip
Perl program ---&gt; source filter ---&gt; parser</code></pre>

<h1 id="USING-FILTERS"><a class="permalink" href="perlfilter.html#USING-FILTERS">#</a><a id="USING"></a>USING FILTERS</h1>

<p>So how do you use a source filter in a Perl script? Above, I said that a source filter is just a special kind of module. Like all Perl modules, a source filter is invoked with a use statement.</p>

<p>Say you want to pass your Perl source through the C preprocessor before execution. As it happens, the source filters distribution comes with a C preprocessor filter module called Filter::cpp.</p>

<p>Below is an example program, <code>cpp_test</code>, which makes use of this filter. Line numbers have been added to allow specific lines to be referenced easily.</p>

<pre><code>1: use Filter::cpp;
2: #define TRUE 1
3: $a = TRUE;
4: print &quot;a = $a\n&quot;;</code></pre>

<p>When you execute this script, Perl creates a source stream for the file. Before the parser processes any of the lines from the file, the source stream looks like this:</p>

<pre><code class="plaintext">cpp_test ---------&gt; parser</code></pre>

<p>Line 1, <code>use Filter::cpp</code>, includes and installs the <code>cpp</code> filter module. All source filters work this way. The use statement is compiled and executed at compile time, before any more of the file is read, and it attaches the cpp filter to the source stream behind the scenes. Now the data flow looks like this:</p>

<pre><code class="plaintext">cpp_test ----&gt; cpp filter ----&gt; parser</code></pre>

<p>As the parser reads the second and subsequent lines from the source stream, it feeds those lines through the <code>cpp</code> source filter before processing them. The <code>cpp</code> filter simply passes each line through the real C preprocessor. The output from the C preprocessor is then inserted back into the source stream by the filter.</p>

<pre><code class="plaintext">               .-&gt; cpp --.
               |         |
               |         |
               |       &lt;-&#39;
cpp_test ----&gt; cpp filter ----&gt; parser</code></pre>

<p>The parser then sees the following code:</p>

<pre><code>use Filter::cpp;
$a = 1;
print &quot;a = $a\n&quot;;</code></pre>

<p>Let&#39;s consider what happens when the filtered code includes another module with use:</p>

<pre><code>1: use Filter::cpp;
2: #define TRUE 1
3: use Fred;
4: $a = TRUE;
5: print &quot;a = $a\n&quot;;</code></pre>

<p>The <code>cpp</code> filter does not apply to the text of the Fred module, only to the text of the file that used it (<code>cpp_test</code>). Although the use statement on line 3 will pass through the cpp filter, the module that gets included (<code>Fred</code>) will not. The source streams look like this after line 3 has been parsed and before line 4 is parsed:</p>

<pre><code class="plaintext">cpp_test ---&gt; cpp filter ---&gt; parser (INACTIVE)

Fred.pm ----&gt; parser</code></pre>

<p>As you can see, a new stream has been created for reading the source from <code>Fred.pm</code>. This stream will remain active until all of <code>Fred.pm</code> has been parsed. The source stream for <code>cpp_test</code> will still exist, but is inactive. Once the parser has finished reading Fred.pm, the source stream associated with it will be destroyed. The source stream for <code>cpp_test</code> then becomes active again and the parser reads line 4 and subsequent lines from <code>cpp_test</code>.</p>

<p>You can use more than one source filter on a single file. Similarly, you can reuse the same filter in as many files as you like.</p>

<p>For example, if you have a uuencoded and compressed source file, it is possible to stack a uudecode filter and an uncompression filter like this:</p>

<pre><code>use Filter::uudecode; use Filter::uncompress;
M&#39;XL(&quot;.H&lt;US4&#39;&#39;V9I;F%L&#39;)Q;&gt;7/;1I;_&gt;_I3=&amp;E=%:F*I&quot;T?22Q/
M6]9*&lt;IQCO*XFT&quot;0[PL%%&#39;Y+IG?WN^ZYN-$&#39;J.[.JE$,20/?K=_[&gt;
...</code></pre>

<p>Once the first line has been processed, the flow will look like this:</p>

<pre><code class="plaintext">file ---&gt; uudecode ---&gt; uncompress ---&gt; parser
           filter         filter</code></pre>

<p>Data flows through filters in the same order they appear in the source file. The uudecode filter appeared before the uncompress filter, so the source file will be uudecoded before it&#39;s uncompressed.</p>

<h1 id="WRITING-A-SOURCE-FILTER"><a class="permalink" href="perlfilter.html#WRITING-A-SOURCE-FILTER">#</a><a id="WRITING"></a>WRITING A SOURCE FILTER</h1>

<p>There are three ways to write your own source filter. You can write it in C, use an external program as a filter, or write the filter in Perl. I won&#39;t cover the first two in any great detail, so I&#39;ll get them out of the way first. Writing the filter in Perl is most convenient, so I&#39;ll devote the most space to it.</p>

<h1 id="WRITING-A-SOURCE-FILTER-IN-C"><a class="permalink" href="perlfilter.html#WRITING-A-SOURCE-FILTER-IN-C">#</a><a id="WRITING1"></a>WRITING A SOURCE FILTER IN C</h1>

<p>The first of the three available techniques is to write the filter completely in C. The external module you create interfaces directly with the source filter hooks provided by Perl.</p>

<p>The advantage of this technique is that you have complete control over the implementation of your filter. The big disadvantage is the increased complexity required to write the filter - not only do you need to understand the source filter hooks, but you also need a reasonable knowledge of Perl guts. One of the few times it is worth going to this trouble is when writing a source scrambler. The <code>decrypt</code> filter (which unscrambles the source before Perl parses it) included with the source filter distribution is an example of a C source filter (see Decryption Filters, below).</p>

<dl>

<dt id="Decryption-Filters"><a class="permalink" href="perlfilter.html#Decryption-Filters">#</a><a id="Decryption"></a><b>Decryption Filters</b></dt>
<dd>

<p>All decryption filters work on the principle of &quot;security through obscurity.&quot; Regardless of how well you write a decryption filter and how strong your encryption algorithm is, anyone determined enough can retrieve the original source code. The reason is quite simple - once the decryption filter has decrypted the source back to its original form, fragments of it will be stored in the computer&#39;s memory as Perl parses it. The source might only be in memory for a short period of time, but anyone possessing a debugger, skill, and lots of patience can eventually reconstruct your program.</p>

<p>That said, there are a number of steps that can be taken to make life difficult for the potential cracker. The most important: Write your decryption filter in C and statically link the decryption module into the Perl binary. For further tips to make life difficult for the potential cracker, see the file <i>decrypt.pm</i> in the source filters distribution.</p>

</dd>
</dl>

<h1 id="CREATING-A-SOURCE-FILTER-AS-A-SEPARATE-EXECUTABLE"><a class="permalink" href="perlfilter.html#CREATING-A-SOURCE-FILTER-AS-A-SEPARATE-EXECUTABLE">#</a><a id="CREATING"></a>CREATING A SOURCE FILTER AS A SEPARATE EXECUTABLE</h1>

<p>An alternative to writing the filter in C is to create a separate executable in the language of your choice. The separate executable reads from standard input, does whatever processing is necessary, and writes the filtered data to standard output. <code>Filter::cpp</code> is an example of a source filter implemented as a separate executable - the executable is the C preprocessor bundled with your C compiler.</p>

<p>The source filter distribution includes two modules that simplify this task: <code>Filter::exec</code> and <code>Filter::sh</code>. Both allow you to run any external executable. Both use a coprocess to control the flow of data into and out of the external executable. (For details on coprocesses, see Stephens, W.R., &quot;Advanced Programming in the UNIX Environment.&quot; Addison-Wesley, ISBN 0-210-56317-7, pages 441-445.) The difference between them is that <code>Filter::exec</code> spawns the external command directly, while <code>Filter::sh</code> spawns a shell to execute the external command. (Unix uses the Bourne shell; NT uses the cmd shell.) Spawning a shell allows you to make use of the shell metacharacters and redirection facilities.</p>

<p>Here is an example script that uses <code>Filter::sh</code>:</p>

<pre><code>use Filter::sh &#39;tr XYZ PQR&#39;;
$a = 1;
print &quot;XYZ a = $a\n&quot;;</code></pre>

<p>The output you&#39;ll get when the script is executed:</p>

<pre><code class="plaintext">PQR a = 1</code></pre>

<p>Writing a source filter as a separate executable works fine, but a small performance penalty is incurred. For example, if you execute the small example above, a separate subprocess will be created to run the Unix <code>tr</code> command. Each use of the filter requires its own subprocess. If creating subprocesses is expensive on your system, you might want to consider one of the other options for creating source filters.</p>

<h1 id="WRITING-A-SOURCE-FILTER-IN-PERL"><a class="permalink" href="perlfilter.html#WRITING-A-SOURCE-FILTER-IN-PERL">#</a><a id="WRITING2"></a>WRITING A SOURCE FILTER IN PERL</h1>

<p>The easiest and most portable option available for creating your own source filter is to write it completely in Perl. To distinguish this from the previous two techniques, I&#39;ll call it a Perl source filter.</p>

<p>To help understand how to write a Perl source filter we need an example to study. Here is a complete source filter that performs rot13 decoding. (Rot13 is a very simple encryption scheme used in Usenet postings to hide the contents of offensive posts. It moves every letter forward thirteen places, so that A becomes N, B becomes O, and Z becomes M.)</p>

<pre><code>package Rot13;

use Filter::Util::Call;

sub import {
   my ($type) = @_;
   my ($ref) = [];
   filter_add(bless $ref);
}

sub filter {
   my ($self) = @_;
   my ($status);

   tr/n-za-mN-ZA-M/a-zA-Z/
      if ($status = filter_read()) &gt; 0;
   $status;
}

1;</code></pre>

<p>All Perl source filters are implemented as Perl classes and have the same basic structure as the example above.</p>

<p>First, we include the <code>Filter::Util::Call</code> module, which exports a number of functions into your filter&#39;s namespace. The filter shown above uses two of these functions, <code>filter_add()</code> and <code>filter_read()</code>.</p>

<p>Next, we create the filter object and associate it with the source stream by defining the <code>import</code> function. If you know Perl well enough, you know that <code>import</code> is called automatically every time a module is included with a use statement. This makes <code>import</code> the ideal place to both create and install a filter object.</p>

<p>In the example filter, the object (<code>$ref</code>) is blessed just like any other Perl object. Our example uses an anonymous array, but this isn&#39;t a requirement. Because this example doesn&#39;t need to store any context information, we could have used a scalar or hash reference just as well. The next section demonstrates context data.</p>

<p>The association between the filter object and the source stream is made with the <code>filter_add()</code> function. This takes a filter object as a parameter (<code>$ref</code> in this case) and installs it in the source stream.</p>

<p>Finally, there is the code that actually does the filtering. For this type of Perl source filter, all the filtering is done in a method called <code>filter()</code>. (It is also possible to write a Perl source filter using a closure. See the <code>Filter::Util::Call</code> manual page for more details.) It&#39;s called every time the Perl parser needs another line of source to process. The <code>filter()</code> method, in turn, reads lines from the source stream using the <code>filter_read()</code> function.</p>

<p>If a line was available from the source stream, <code>filter_read()</code> returns a status value greater than zero and appends the line to <code>$_</code>. A status value of zero indicates end-of-file, less than zero means an error. The filter function itself is expected to return its status in the same way, and put the filtered line it wants written to the source stream in <code>$_</code>. The use of <code>$_</code> accounts for the brevity of most Perl source filters.</p>

<p>In order to make use of the rot13 filter we need some way of encoding the source file in rot13 format. The script below, <code>mkrot13</code>, does just that.</p>

<pre><code>die &quot;usage mkrot13 filename\n&quot; unless @ARGV;
my $in = $ARGV[0];
my $out = &quot;$in.tmp&quot;;
open(IN, &quot;&lt;$in&quot;) or die &quot;Cannot open file $in: $!\n&quot;;
open(OUT, &quot;&gt;$out&quot;) or die &quot;Cannot open file $out: $!\n&quot;;

print OUT &quot;use Rot13;\n&quot;;
while (&lt;IN&gt;) {
   tr/a-zA-Z/n-za-mN-ZA-M/;
   print OUT;
}

close IN;
close OUT;
unlink $in;
rename $out, $in;</code></pre>

<p>If we encrypt this with <code>mkrot13</code>:</p>

<pre><code>print &quot; hello fred \n&quot;;</code></pre>

<p>the result will be this:</p>

<pre><code>use Rot13;
cevag &quot;uryyb serq\a&quot;;</code></pre>

<p>Running it produces this output:</p>

<pre><code class="plaintext">hello fred</code></pre>

<h1 id="USING-CONTEXT:-THE-DEBUG-FILTER"><a class="permalink" href="perlfilter.html#USING-CONTEXT:-THE-DEBUG-FILTER">#</a><a id="USING1"></a>USING CONTEXT: THE DEBUG FILTER</h1>

<p>The rot13 example was a trivial example. Here&#39;s another demonstration that shows off a few more features.</p>

<p>Say you wanted to include a lot of debugging code in your Perl script during development, but you didn&#39;t want it available in the released product. Source filters offer a solution. In order to keep the example simple, let&#39;s say you wanted the debugging output to be controlled by an environment variable, <code>DEBUG</code>. Debugging code is enabled if the variable exists, otherwise it is disabled.</p>

<p>Two special marker lines will bracket debugging code, like this:</p>

<pre><code>## DEBUG_BEGIN
if ($year &gt; 1999) {
   warn &quot;Debug: millennium bug in year $year\n&quot;;
}
## DEBUG_END</code></pre>

<p>The filter ensures that Perl parses the code between the &lt;DEBUG_BEGIN&gt; and <code>DEBUG_END</code> markers only when the <code>DEBUG</code> environment variable exists. That means that when <code>DEBUG</code> does exist, the code above should be passed through the filter unchanged. The marker lines can also be passed through as-is, because the Perl parser will see them as comment lines. When <code>DEBUG</code> isn&#39;t set, we need a way to disable the debug code. A simple way to achieve that is to convert the lines between the two markers into comments:</p>

<pre><code>## DEBUG_BEGIN
#if ($year &gt; 1999) {
#     warn &quot;Debug: millennium bug in year $year\n&quot;;
#}
## DEBUG_END</code></pre>

<p>Here is the complete Debug filter:</p>

<pre><code>package Debug;

use strict;
use warnings;
use Filter::Util::Call;

use constant TRUE =&gt; 1;
use constant FALSE =&gt; 0;

sub import {
   my ($type) = @_;
   my (%context) = (
     Enabled =&gt; defined $ENV{DEBUG},
     InTraceBlock =&gt; FALSE,
     Filename =&gt; (caller)[1],
     LineNo =&gt; 0,
     LastBegin =&gt; 0,
   );
   filter_add(bless \%context);
}

sub Die {
   my ($self) = shift;
   my ($message) = shift;
   my ($line_no) = shift || $self-&gt;{LastBegin};
   die &quot;$message at $self-&gt;{Filename} line $line_no.\n&quot;
}

sub filter {
   my ($self) = @_;
   my ($status);
   $status = filter_read();
   ++ $self-&gt;{LineNo};

   # deal with EOF/error first
   if ($status &lt;= 0) {
       $self-&gt;Die(&quot;DEBUG_BEGIN has no DEBUG_END&quot;)
           if $self-&gt;{InTraceBlock};
       return $status;
   }

   if ($self-&gt;{InTraceBlock}) {
      if (/^\s*##\s*DEBUG_BEGIN/ ) {
          $self-&gt;Die(&quot;Nested DEBUG_BEGIN&quot;, $self-&gt;{LineNo})
      } elsif (/^\s*##\s*DEBUG_END/) {
          $self-&gt;{InTraceBlock} = FALSE;
      }

      # comment out the debug lines when the filter is disabled
      s/^/#/ if ! $self-&gt;{Enabled};
   } elsif ( /^\s*##\s*DEBUG_BEGIN/ ) {
      $self-&gt;{InTraceBlock} = TRUE;
      $self-&gt;{LastBegin} = $self-&gt;{LineNo};
   } elsif ( /^\s*##\s*DEBUG_END/ ) {
      $self-&gt;Die(&quot;DEBUG_END has no DEBUG_BEGIN&quot;, $self-&gt;{LineNo});
   }
   return $status;
}

1;</code></pre>

<p>The big difference between this filter and the previous example is the use of context data in the filter object. The filter object is based on a hash reference, and is used to keep various pieces of context information between calls to the filter function. All but two of the hash fields are used for error reporting. The first of those two, Enabled, is used by the filter to determine whether the debugging code should be given to the Perl parser. The second, InTraceBlock, is true when the filter has encountered a <code>DEBUG_BEGIN</code> line, but has not yet encountered the following <code>DEBUG_END</code> line.</p>

<p>If you ignore all the error checking that most of the code does, the essence of the filter is as follows:</p>

<pre><code>sub filter {
   my ($self) = @_;
   my ($status);
   $status = filter_read();

   # deal with EOF/error first
   return $status if $status &lt;= 0;
   if ($self-&gt;{InTraceBlock}) {
      if (/^\s*##\s*DEBUG_END/) {
         $self-&gt;{InTraceBlock} = FALSE
      }

      # comment out debug lines when the filter is disabled
      s/^/#/ if ! $self-&gt;{Enabled};
   } elsif ( /^\s*##\s*DEBUG_BEGIN/ ) {
      $self-&gt;{InTraceBlock} = TRUE;
   }
   return $status;
}</code></pre>

<p>Be warned: just as the C-preprocessor doesn&#39;t know C, the Debug filter doesn&#39;t know Perl. It can be fooled quite easily:</p>

<pre><code>print &lt;&lt;EOM;
##DEBUG_BEGIN
EOM</code></pre>

<p>Such things aside, you can see that a lot can be achieved with a modest amount of code.</p>

<h1 id="CONCLUSION"><a class="permalink" href="perlfilter.html#CONCLUSION">#</a>CONCLUSION</h1>

<p>You now have better understanding of what a source filter is, and you might even have a possible use for them. If you feel like playing with source filters but need a bit of inspiration, here are some extra features you could add to the Debug filter.</p>

<p>First, an easy one. Rather than having debugging code that is all-or-nothing, it would be much more useful to be able to control which specific blocks of debugging code get included. Try extending the syntax for debug blocks to allow each to be identified. The contents of the <code>DEBUG</code> environment variable can then be used to control which blocks get included.</p>

<p>Once you can identify individual blocks, try allowing them to be nested. That isn&#39;t difficult either.</p>

<p>Here is an interesting idea that doesn&#39;t involve the Debug filter. Currently Perl subroutines have fairly limited support for formal parameter lists. You can specify the number of parameters and their type, but you still have to manually take them out of the <code>@_</code> array yourself. Write a source filter that allows you to have a named parameter list. Such a filter would turn this:</p>

<pre><code>sub MySub ($first, $second, @rest) { ... }</code></pre>

<p>into this:</p>

<pre><code>sub MySub($$@) {
   my ($first) = shift;
   my ($second) = shift;
   my (@rest) = @_;
   ...
}</code></pre>

<p>Finally, if you feel like a real challenge, have a go at writing a full-blown Perl macro preprocessor as a source filter. Borrow the useful features from the C preprocessor and any other macro processors you know. The tricky bit will be choosing how much knowledge of Perl&#39;s syntax you want your filter to have.</p>

<h1 id="LIMITATIONS"><a class="permalink" href="perlfilter.html#LIMITATIONS">#</a>LIMITATIONS</h1>

<p>Source filters only work on the string level, thus are highly limited in its ability to change source code on the fly. It cannot detect comments, quoted strings, heredocs, it is no replacement for a real parser. The only stable usage for source filters are encryption, compression, or the byteloader, to translate binary code back to source code.</p>

<p>See for example the limitations in <a href="Switch.html">Switch</a>, which uses source filters, and thus is does not work inside a string eval, the presence of regexes with embedded newlines that are specified with raw <code>/.../</code> delimiters and don&#39;t have a modifier <code>//x</code> are indistinguishable from code chunks beginning with the division operator <code>/</code>. As a workaround you must use <code>m/.../</code> or <code>m?...?</code> for such patterns. Also, the presence of regexes specified with raw <code>?...?</code> delimiters may cause mysterious errors. The workaround is to use <code>m?...?</code> instead. See <a href="Switch.html#LIMITATIONS">https://metacpan.org/pod/Switch#LIMITATIONS</a>.</p>

<p>Currently the content of the <code>__DATA__</code> block is not filtered.</p>

<p>Currently internal buffer lengths are limited to 32-bit only.</p>

<h1 id="THINGS-TO-LOOK-OUT-FOR"><a class="permalink" href="perlfilter.html#THINGS-TO-LOOK-OUT-FOR">#</a><a id="THINGS"></a>THINGS TO LOOK OUT FOR</h1>

<dl>

<dt id="Some-Filters-Clobber-the-DATA-Handle"><a class="permalink" href="perlfilter.html#Some-Filters-Clobber-the-DATA-Handle">#</a><a id="Some"></a>Some Filters Clobber the <code>DATA</code> Handle</dt>
<dd>

<p>Some source filters use the <code>DATA</code> handle to read the calling program. When using these source filters you cannot rely on this handle, nor expect any particular kind of behavior when operating on it. Filters based on Filter::Util::Call (and therefore Filter::Simple) do not alter the <code>DATA</code> filehandle, but on the other hand totally ignore the text after <code>__DATA__</code>.</p>

</dd>
</dl>

<h1 id="REQUIREMENTS"><a class="permalink" href="perlfilter.html#REQUIREMENTS">#</a>REQUIREMENTS</h1>

<p>The Source Filters distribution is available on CPAN, in</p>

<pre><code class="plaintext">CPAN/modules/by-module/Filter</code></pre>

<p>Starting from Perl 5.8 Filter::Util::Call (the core part of the Source Filters distribution) is part of the standard Perl distribution. Also included is a friendlier interface called Filter::Simple, by Damian Conway.</p>

<h1 id="AUTHOR"><a class="permalink" href="perlfilter.html#AUTHOR">#</a>AUTHOR</h1>

<p>Paul Marquess &lt;Paul.Marquess@btinternet.com&gt;</p>

<p>Reini Urban &lt;rurban@cpan.org&gt;</p>

<h1 id="Copyrights"><a class="permalink" href="perlfilter.html#Copyrights">#</a>Copyrights</h1>

<p>The first version of this article originally appeared in The Perl Journal #11, and is copyright 1998 The Perl Journal. It appears courtesy of Jon Orwant and The Perl Journal. This document may be distributed under the same terms as Perl itself.</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
